﻿using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using Microsoft.Phone.Controls;
using SlideView.Library;

namespace DepSoft.Mobile.WP8.FollwIt.View
{
    public partial class FollwItPage : PhoneApplicationPage
    {
        public FollwItPage()
        {
            InitializeComponent();            
            //var rootFrame = ((App)Application.Current).RootFrame;
            SlideApplicationFrame rootFrame = (SlideApplicationFrame)App.RootFrame;
            rootFrame.IsSlideEnabled = false;
            rootFrame.IsHeaderVisible = false;

            this.Loaded += OnLoaded;
        }

        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            if(this.LoginPanel.Visibility == Visibility.Visible)
                this.UserName.Focus();
            else
                this.DisconnectButton.Focus();
        }

        private void OnMediaEnded(object sender, RoutedEventArgs e)
        {
            this.VideoBackground.Visibility = Visibility.Visible;
            var mediaElement = sender as MediaElement;            
            if (mediaElement != null)
            {
                this.VideoBackground.Visibility = Visibility.Collapsed;
                mediaElement.Position = TimeSpan.Zero;
                mediaElement.Play();
            }
        }
    }
}